<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<div class="modal-dialog x-modal-dialog" style="width: 650px; margin-top: 100px;">

	<div class="modal-content">

		<div class="modal-header x-breadcrumb no-bottom-border clearfix">

			<h2>
				<i class="glyphicon glyphicon-fire" title="导出"></i>&nbsp;&nbsp;<span>用户列表&nbsp;-&nbsp;导出</span>
			</h2>

			<button type="button" class="close" data-dismiss="modal">&times;</button>

		</div>

		<form class="form-horizontal" method="GET" action="${ctx.host}/${type}-students/export" data-validate="true">

			<input type="hidden" name="siteId" value="${siteId}"></input>
			<div class="modal-body">

				<div class="form-group x-form-group">
					
					<label class="col-xs-3 control-label">开始时间</label>
					<div class="col-xs-7 pull-left" style="width: 65%">
						<div class="input-group">
							<input type="text" class="form-control date" name="startTime" data-validate="required"/>
							<span class="input-group-addon">至</span>
							<input type="text" class="form-control date" name="endTime" data-validate="required"/>
						</div>
					</div>
				</div>

			</div>

			<div class="modal-footer">
				<button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">查询</button>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
			</div>

		</form>

	</div>

</div>

<script type="text/javascript">
	
	function checkData(){
		
		var $startTime = $('input[name=startTime]').val();
		var $endTime = $('input[name=endTime]').val();
	
		var startTime = new Date($startTime.replace("-","/").replace("-","/"));
		var endTime = new Date($endTime.replace("-","/").replace("-","/"));
		
		var nextMonthStartTime = new Date(startTime);
		nextMonthStartTime.setMonth(startTime.getMonth()+1)
		
		if(startTime > endTime){
			$('input[name=startTime]').parents(".input-group").show_err_tooltip('开始时间大于结束时间');
			return false;
		}
		
		if(endTime > nextMonthStartTime){
			$('input[name=startTime]').parents(".input-group").show_err_tooltip('间隔时间不能超过一个月');
			return false;
		}
		var $form = $(document).find("form") //bind shiftform
		$form.trigger("validate.ajax.submit");
		return $.bt_validate.result[$.bt_validate.form_id];
	}


	$(document).ready(function() {
		$('.date').datetimepicker({
			format : 'yyyy-mm-dd',
			autoclose : true,
			language : 'zh-CN',
			todayBtn : 'linked',
			todayHighlight : true,
			pickerPosition : 'bottom-right',
			minView : 'month'
		});

		$(document).find('form[data-validate="true"]').bt_validate() //bind validate

		var $submitButton = $('button[type=submit]');
		
		$submitButton.click(function(){
			if(checkData()){
				var $form = $(document).find("form");
				$form.submit();
				$('#online-student-export').modal('toggle');
			}else{
				return false;
			}
		});
		
		
		
		
		
	})
</script>
